/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package SessionBeans;

import Entidades.Person;
import javax.ejb.Stateless;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author Pedro
 */
@Stateless
public class PersonFacade extends AbstractFacade<Person> {
    @PersistenceContext(unitName = "WebApplicationPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }
    
    public Person find(String login){
        Query q = null;
        q= (Query) em.createQuery("select p FROM Person p where p.login = :login");
        q.setParameter("login", login);
        
        
        return (Person) q.getSingleResult();
    }

    public PersonFacade() {
        super(Person.class);
    }
    
}
